//
//  ZAQSearchView.swift
//  ZAQWBDZT
//
//  Created by 赵安庆 on 16/9/19.
//  Copyright © 2016年 zaq. All rights reserved.
//

import UIKit

class ZAQSearchView: UIView {

    @IBOutlet weak var rightContraint: NSLayoutConstraint!
    @IBOutlet weak var searchButton: UIButton!
    @IBOutlet weak var searchTextField: UITextField!

    @IBAction func searchButtonAction(_ sender: AnyObject) {
       searchTextField.resignFirstResponder()
        rightContraint.constant = 0
        UIView.animate(withDuration: 0.3) { 
            self.layoutIfNeeded()
        }
    }
    @IBAction func textFieldAction(_ sender: AnyObject) {
        rightContraint.constant = searchButton.width
        UIView .animate(withDuration: 0.3) { 
            self.layoutIfNeeded()
        }
    }

    class func searchView() -> ZAQSearchView{
        return UINib(nibName: "ZAQSearchView", bundle: nil).instantiate(withOwner: nil, options: nil).last! as! ZAQSearchView
    }
        override func awakeFromNib() {
            searchTextField.layer.borderColor = UIColor.magenta.cgColor
            searchTextField.layer.borderWidth = 2
            searchTextField.layer.cornerRadius = 5
            searchTextField.layer.masksToBounds = true
        }

}
